<?php include('../variables/variables.php'); ?>

<?php

if(!session_id()) session_start(); 
$con = mysql_connect($dbserver, $dbuser, $dbpass);
if ($con)
{
	mysql_select_db($db, $con);

	if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['password']) && isset($_POST['privilege']))
	{
		$q = fquery($add_employee, array($_POST['name'], $_POST['email'], $_POST['password'], $_POST['privilege']));
		$result = mysql_query($q);
		mysql_close($con);
		if ($result)
		{
			header("location: /admin.php?msg=New emplyee added successfully");
		}
		else
		{
			header("location: /add_employee.php?err=Failed to add the new employee to the system");
		}
	}
	else
	{
		mysql_close($con);
		header("location: /add_employee.php?err=Please fill in all fields".$_POST['name'].$_POST['email'].$_POST['password'].$_POST['phone_number'].$_POST['privilege']);
	}
}

?>
